package com.share.dubbo.ssm.manager.impl;

import com.share.dubbo.ssm.manager.JavaLogManager;
import com.share.dubbo.ssm.model.req.JavaLogCountReq;
import com.share.dubbo.ssm.model.mongo.JavaLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

//@Service
public class JavaLogManagerImpl implements JavaLogManager {
    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public void save(JavaLog record) {
        mongoTemplate.save(record);
    }

    @Override
    public long count(JavaLogCountReq req) {
        Criteria criteria1 = Criteria.where("id").is(req.getId());
        Criteria criteria2 = Criteria.where("id").is(req.getId());
        return mongoTemplate.count(new Query(new Criteria().andOperator(criteria1, criteria2)), JavaLog.class);
    }
}
